package FiveChessGame;

//download by http://www.codefans.net
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
/**
 * 
 *****************************************************
 * <hr>
 * <dt><span class="strong">类功能简介:</span></dt>
 * <dd>Coffee</dd>
 * <dt><span class="strong">创建时间:</span></dt>
 * <dd>2015-3-24 上午10:24:07</dd>
 * <dt><span class="strong">公司:</span></dt>
 * <dd>对话框</dd>
 * @author aa1000777 - Email:aa1000777@qq.com
 *****************************************************
 */
public class WinDialog extends JDialog implements ActionListener {

	private static final long serialVersionUID = 1L;

	boolean restartflag = false;

	public WinDialog(JFrame jframe, int userFlag) {
		// TODO Auto-generated constructor stub
		super(jframe, (userFlag == 1 ? "黑棋" : "白棋") + "嬴啦!!!", true);
		this.setLayout(new FlowLayout());
		JButton yesButton = new JButton("继续");
		JButton noButton = new JButton("取消");
		JLabel tipLabel = new JLabel("恭喜 " + (userFlag == 1 ? "黑棋" : "白棋") + " 旗开得胜!!");
		yesButton.addActionListener(this);
		yesButton.setActionCommand("Yes");
		noButton.addActionListener(this);
		noButton.setActionCommand("No");

		this.add(tipLabel);
		this.add(yesButton);
		this.add(noButton);

		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.setLocation(400, 350);
		this.setSize(180, 100);
		this.setResizable(false);
		this.setVisible(true);

	}

	public boolean getButtonPrassed() {

		return restartflag;
	}

	public void actionPerformed(ActionEvent arg0) {
		if (arg0.getActionCommand() == "Yes") {
			System.out.println("YesPrassDown");
			restartflag = true;
			this.dispose();
			this.toBack();

		} else {
			System.out.println("NoPrassDown");
			restartflag = false;
			this.dispose();
			this.toBack();
		}
	}
}
